package com.leyou.order.controller;

import com.leyou.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author syf
 * @version 1.0
 * @date 2019/08/20 10:08
 * @Description TODO:
 */
@RestController
@RequestMapping("pay")
public class PayController {

    @Autowired
    private OrderService orderService;
    //微信支付结果通知
    //微信支付信息回调
    @PostMapping(value = "/wx/notify",produces = "application/xml")
    public Map<String,String> receiveWxNodeResult(@RequestBody Map<String,String> resultMa){
        orderService.handlerOrder(resultMa);
        //此时客户的钱已经支付成功了，直接告诉微信成功不要随意抛异常
        Map<String,String> helloMap=new HashMap<>();
        helloMap.put("return_code","SUCCESS");//返回状态码
        helloMap.put("return_msg","OK");//返回信息
        return helloMap;
    }


}
